package com.wms.controller;

import com.wms.common.CallBack;
import com.wms.common.Response;
import com.wms.domain.PickingDomain;
import com.wms.domain.OutStoreDetailDomain;
import com.wms.domain.OutStoreIdxDomain;
import com.wms.dto.OutStoreDetailDto;
import com.wms.service.OutStore.OutStoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "出库管理")
@RequestMapping(path = "/OutStore/")
@RestController
public class OutStore {
    @Autowired
    OutStoreService outStoreService;

    @ApiOperation(value="新增发货单")
    @RequestMapping(path="addDeliver",method= RequestMethod.POST)
    public Response addDeliver(@RequestBody OutStoreIdxDomain outStoreIdxDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return outStoreService.addDeliver(outStoreIdxDomain);
            }
        }.execute();
    }

    @ApiOperation(value="查询发货单")
    @RequestMapping(path="getDeliverPage",method= RequestMethod.POST)
    public Response getDeliverPage(@RequestBody OutStoreIdxDomain outStoreIdxDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return outStoreService.getDeliverPage(outStoreIdxDomain);
            }
        }.execute();
    }

    @ApiOperation(value="查询发货单详情")
    @RequestMapping(path="getDeliverDetailPage",method= RequestMethod.POST)
    public Response getDeliverDetailPage(@RequestBody OutStoreDetailDto outStoreDetailDto){
        return new CallBack() {
            @Override
            protected Object run() {
                return outStoreService.getDeliverDetailPage(outStoreDetailDto);
            }
        }.execute();
    }

    @ApiOperation(value="修改发货单详情")
    @RequestMapping(path="updateDeliverDetail",method= RequestMethod.POST)
    public Response updateDeliverDetail(@RequestBody OutStoreDetailDomain outStoreDetailDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return outStoreService.updateDetail(outStoreDetailDomain);
            }
        }.execute();
    }

    @ApiOperation(value="新增拣货详情")
    @RequestMapping(path="addPicking",method= RequestMethod.POST)
    public Response addPicking(@RequestBody List<PickingDomain> pickingDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return outStoreService.addPicking(pickingDomain);
            }
        }.execute();
    }

    @ApiOperation(value="查询拣货详情")
    @RequestMapping(path="getPicking",method= RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "g_id", value = "g_id", required = true),
            @ApiImplicitParam(name = "store_detail_id", value = "store_detail_id", required = true) })
    public Response getPicking(final Long g_id,final Long store_detail_id){
        return new CallBack() {
            @Override
            protected Object run() {
                return outStoreService.getPicking(g_id,store_detail_id);
            }
        }.execute();
    }

    @ApiOperation(value="查询待出库")
    @RequestMapping(path="getSportPage",method= RequestMethod.POST)
    public Response getSportPage(@RequestBody OutStoreIdxDomain outStoreIdxDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return outStoreService.getSportPage(outStoreIdxDomain);
            }
        }.execute();
    }

    @ApiOperation(value="确认出库")
    @RequestMapping(path="confirmOutStore",method= RequestMethod.POST)
    @ApiImplicitParam(name = "id", value = "id", required = true)
    public Response confirmOutStore(final Long id){
        return new CallBack() {
            @Override
            protected Object run() {
                return outStoreService.confirmOutStore(id);
            }
        }.execute();
    }

}
